package com.healthcloud.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.healthcloud.entity.FoodGuidance;
import com.healthcloud.service.FoodGuidanceService;
import com.healthcloud.utils.ApiRes;
import com.healthcloud.utils.PageParam;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 健康教育 饮食指导库
 * Created by houxianghua on 2016/5/10.
 */
@ApiIgnore
@Api(value = "示例说明", description = "健康教育 饮食指导库")
@RestController
@RequestMapping(value = "/app/dean/healthEducation/foodGuidance")
public class FoodGuidanceApiController {

    @Autowired
    private FoodGuidanceService foodGuidanceService;

    /**
     * 获取所有列表
     * @param foodGuidance
     * @return
     */
	@ApiOperation(value = "获取所有列表",notes ="获取所有列表")
    @RequestMapping(value = "/getAll")
    public Object getAll(FoodGuidance foodGuidance) {
        List<FoodGuidance> foodGuidanceList = foodGuidanceService.findByEntity(foodGuidance);
        for (FoodGuidance fg : foodGuidanceList){
            fg.setCreatedTime(null);
            fg.setUpdatedTime(null);
        }
        return new ApiRes(foodGuidanceList);
    }

    /**
     * 获取热门食谱
     * @param foodName  食谱名称（模糊查询）
     * @param pageParam 分页数据(iDisplayStart:开始位置，iDisplayLength:返回长度)
     * @return
     */
	@ApiOperation(value = "获取热门食谱",notes ="获取热门食谱")
    @RequestMapping(value = "/getHotFood")
    public Object getHotFood(String foodName, PageParam pageParam) {
        List<FoodGuidance> foodGuidanceList = foodGuidanceService.getHotFood(foodName, pageParam);
        for (FoodGuidance fg : foodGuidanceList){
            fg.setCreatedTime(null);
            fg.setUpdatedTime(null);
        }
        return new ApiRes(foodGuidanceList);
    }

    /**
     * 获取最新食谱
     * @param foodName  食谱名称（模糊查询）
     * @param pageParam 分页数据(iDisplayStart:开始位置，iDisplayLength:返回长度)
     * @return
     */
	@ApiOperation(value = "获取最新食谱",notes ="获取最新食谱")
    @RequestMapping(value = "/getNewFood")
    public Object getNewFood(String foodName, PageParam pageParam) {
        List<FoodGuidance> foodGuidanceList = foodGuidanceService.getNewFood(foodName, pageParam);
        for (FoodGuidance fg : foodGuidanceList){
            fg.setCreatedTime(null);
            fg.setUpdatedTime(null);
        }
        return new ApiRes(foodGuidanceList);
    }

//    /**
//     * 添加关注
//     * @param foodGuidanceId    食谱id
//     * @param userId            用户id
//     * @return
//     */
//    @RequestMapping(value = "/giveConcern")
//    public Object giveConcern(Long foodGuidanceId, Long userId) {
//        List<FoodGuidance> foodGuidanceList = foodGuidanceService.giveConcern(foodGuidanceId, userId);
//        if (foodGuidanceList == null) {
//            return new JsonMsg(false, null, "", "未查询到结果");
//        }
//        return new JsonMsg(foodGuidanceList);
//    }
//
//    /**
//     * 点赞
//     * @param foodGuidance
//     * @param pageParam
//     * @return
//     */
//    @RequestMapping(value = "/givePraise")
//    public Object givePraise(FoodGuidance foodGuidance, PageParam pageParam) {
//        List<FoodGuidance> foodGuidanceList = foodGuidanceService.getNewFood(foodGuidance, pageParam);
//        if (foodGuidanceList == null) {
//            return new JsonMsg(false, null, "", "未查询到结果");
//        }
//        return new JsonMsg(foodGuidanceList);
//    }
//
//    /**
//     * 获取关注列表
//     * @param foodGuidance
//     * @param pageParam
//     * @return
//     */
//    @RequestMapping(value = "/getGiveConcernList")
//    public Object getGiveConcernList(FoodGuidance foodGuidance, PageParam pageParam) {
//        List<FoodGuidance> foodGuidanceList = foodGuidanceService.getNewFood(foodGuidance, pageParam);
//        if (foodGuidanceList == null) {
//            return new JsonMsg(false, null, "", "未查询到结果");
//        }
//        return new JsonMsg(foodGuidanceList);
//    }
//
//    /**
//     * 获取点赞列表
//     * @param foodGuidance
//     * @param pageParam
//     * @return
//     */
//    @RequestMapping(value = "/getGivePraiseList")
//    public Object getGivePraiseList(FoodGuidance foodGuidance, PageParam pageParam) {
//        List<FoodGuidance> foodGuidanceList = foodGuidanceService.getNewFood(foodGuidance, pageParam);
//        if (foodGuidanceList == null) {
//            return new JsonMsg(false, null, "", "未查询到结果");
//        }
//        return new JsonMsg(foodGuidanceList);
//    }
}
